/*
 * Created on 2006-5-18 0:49:42
 */
package cn.com.sbell.vss.csg.vap;

import org.dom4j.Element;

import cn.com.sbell.vss.VssConstants;
import cn.com.sbell.vss.VssException;
import cn.com.sbell.vss.csg.vsclient.VsClient;
import cn.com.sbell.vss.csg.vsclient.util.PropertiesHolder;

/**
 * @author liang.a.chen
 */
public class StopVsLocalStorageTask extends ProtectedVsCommander {

	protected Element executeCommand(VsClient vsClient, PropertiesHolder holder, Element root) {
		Integer videoId = holder.getIntProperty("videoId");
		if(videoId == null){
			throw new VssException(VssConstants.CODE_REQUIRED,new String[]{"csg.videoId"});
		}
		boolean isStop = "1".equals(holder.getStrProperty("recordEnable"))?false:true;
		if(!vsClient.stopVsLocalStorageTask(videoId.intValue(), isStop)){
			throw new VssException(VssConstants.CODE_STOP_VS_LOCAL_STORAGE_TASK_FAILED);
		}
		return root;
	}
}
